package com.sky.orangehireserver.modules.enterprise.controller;

import com.sky.orangehireserver.utils.ResumeParseUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.apache.tika.exception.TikaException;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.xml.sax.SAXException;

import java.io.IOException;

@Tag(description = "企业端-简历管理", name = "企业端-简历相关接口")
@RestController
@RequestMapping("/api/resume")
public class EnterpriseResumeController {
    @Resource
    private ResumeParseUtil resumeParseUtil;

    @PostMapping("/upload")
    @Operation(summary = "简历解析")
    public String upload(@RequestParam("file") MultipartFile file)
            throws IOException, TikaException, SAXException {
        // 校验文件类型大小可选
        try (var is = file.getInputStream()) {
            return resumeParseUtil.parseWithMetadata(is);
        }
    }
}
